const router = require('koa-router')()
const playerAPI = require('../controllers/player')

router
  .get('/api/getOpenid', async(ctx) => { // 用wx.login的code获取openid
    console.log(ctx.request.query.code)
    ctx.body = await playerAPI.getOpenid(ctx.request.query.code)
  })
  .get('/api/color/rank', async(ctx) => { // 获取排行榜列表 以及获取我的成绩
    console.log(ctx.request.query.openid)
    ctx.body = await playerAPI.getRank(ctx.request.query.openid)
  })
  .post('/api/color/score', async(ctx) => { // 上传我的成绩
    console.log(ctx.request.body)
    ctx.body = await playerAPI.updateMyScore(ctx.request.body)
  })

  module.exports = router